
package com.platform.modules.mall.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.platform.common.utils.Query;
import com.platform.modules.mall.dao.MallOrderGoodsDao;
import com.platform.modules.mall.entity.MallOrderEntity;
import com.platform.modules.mall.entity.MallOrderGoodsEntity;
import com.platform.modules.mall.entity.MallUserCardEntity;
import com.platform.modules.mall.service.MallOrderGoodsService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * 订单详情Service实现类
 *
 * @author
 * @date 2019-07-05 19:29:18
 */
@Service("mallOrderGoodsService")
public class MallOrderGoodsServiceImpl extends ServiceImpl<MallOrderGoodsDao, MallOrderGoodsEntity> implements MallOrderGoodsService {

    @Override
    public List<MallOrderGoodsEntity> queryAll(Map<String, Object> params) {
        return baseMapper.queryAll(params);
    }

    @Override
    public Page queryPage(Map<String, Object> params) {
        //排序
        params.put("sidx", "T.ID");
        params.put("asc", false);
        Page<MallOrderGoodsEntity> page = new Query<MallOrderGoodsEntity>(params).getPage();
        return page.setRecords(baseMapper.selectMallOrderGoodsPage(page, params));
    }

    @Override
    public boolean add(MallOrderGoodsEntity mallOrderGoods) {
        return this.save(mallOrderGoods);
    }

    @Override
    public boolean update(MallOrderGoodsEntity mallOrderGoods) {
        return this.updateById(mallOrderGoods);
    }

    @Override
    public boolean delete(String id) {
        return this.removeById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean deleteBatch(String[] ids) {
        return this.removeByIds(Arrays.asList(ids));
    }

    @Override
    public MallOrderGoodsEntity queryUserBuyNumber(MallOrderGoodsEntity orderGoodsEntity) {
        return baseMapper.queryUserBuyNumber(orderGoodsEntity);
    }

    @Override
    public MallOrderEntity queryUserRecord(MallUserCardEntity userCardEntity) {
        return baseMapper.queryUserRecord(userCardEntity);
    }

    @Override
    public MallOrderGoodsEntity querySumMarketPrice(String orderId) {
        return baseMapper.querySumMarketPrice(orderId);
    }
}
